//
//  Emoticon.swift
//  testEmojKeyBoard
//
//  Created by lujun on 2021/11/23.
//

import UIKit

class Emoticon: NSObject {
    @objc  var code: String? {
        didSet {
            guard let code = code else {
                return
            }
            let sc = Scanner(string: code)
            var value: UInt32 = 0
            sc.scanHexInt32(&value)
            let c = Character(Unicode.Scalar(value)!)
            emojiCode = String(c)
        }
    }
    @objc  var png: String? {
        didSet {
            guard let png = png else {
                return
            }
            pngPath = Bundle.main.bundlePath + "/Emoticons.bundle/" + png
        }
    }
    
    //。普通表情的对应的图片名称
    @objc var chs: String? // //普通表情对应的文字
    @objc var pngPath: String?
    @objc var emojiCode: String?
   
    @objc var isRemove: Bool = false
    
    @objc var isEmpty: Bool = false
    
    init(isEmpty: Bool){
        self.isEmpty = isEmpty
    }
    init(isRemove: Bool){
        self.isRemove = isRemove
    }
    
    init(dict:[String: String]) {
        super.init()
        setValuesForKeys(dict)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {}
    override var description: String{
        let key = ["chs","code","png","emojiCode"]
        
       return dictionaryWithValues(forKeys: key).description
        
  }
}
